<template>
  <div class="app-container">
    <div class="printContent2">
      <div class="print-area print-item" style="width: 95%" v-for="(item, index) in sumEmpoilyeTableDate">
        <div class="center size-24 title">{{ $t(`Print.SummaryTableOfCutParts`) }}</div>

        <div class="mainTable">
          <div :key="index1" v-for="(item2, index1) in item.list">
            <div v-if="(index1 + 2) % rowsPerPage === 0">
              <span style="margin-left: 20px">{{ $t(`Print.Operator`) }}:{{ item.name }}</span>
              <span style="margin-left: 20px">{{ $t(`Print.Department`) }}:{{ item.deptName }}</span>
              <span style="margin-left: 20px">{{ $t(`Print.DateOfManufacture`) }}:01/01-01/01</span>
              <span style="margin-left: 300px">{{ $t(`Print.DateOfPrinting`) }}:{{ formatCurrentDateTime(currentDate) }}</span>
            </div>
          </div>
          <table class="table123" style="text-align: center; font-size: 16px; margin-top: 10px">
            <thead>
              <tr>
                <th class="size-16 center">{{ $t(`Print.Type`) }}</th>
                <th class="size-16 center">{{ $t(`Print.DateOfManufacture`) }}</th>
                <th class="size-16 center">{{ $t(`Print.Body`) }}</th>
                <th class="size-16 center">{{ $t(`Print.Directives`) }}</th>
                <th class="size-16 center">{{ $t(`Print.Place`) }}</th>
                <th class="size-16 center">{{ $t(`Print.Cuttinglayers`) }}</th>
                <th class="size-16 center">{{ $t(`Print.NumberOfPieces`) }}</th>
                <th class="size-16 center">{{ $t(`Print.NumberOfOrders`) }}</th>
                <th class="size-16 center">{{ $t(`Print.DispatchPairs`) }}</th>
                <th class="size-16 center">{{ $t(`Print.UnitPrice`) }}</th>
                <th class="size-16 center">{{ $t(`Print.Amount`) }}</th>
                <th class="size-16 center">{{ $t(`Print.SettlementMonth`) }}</th>
                <th class="size-16 center">{{ $t(`Print.Remark`) }}</th>
              </tr>
            </thead>
            <tbody>
              <template :key="index1" v-for="(item2, index1) in item.list">
                <!-- <tr v-if="(index1 !== 0 && (index1 + 2) % rowsPerPage === 0)">  
                  <td class="size-16 center">{{ item.name }}</td>  
                  <td class="size-16 center">{{ item.deptName }}</td>  
                </tr>   -->
                <tr>
                  <td class="size-16 center">{{ item2.type }}</td>
                  <td class="size-16 center">{{ item2.dispatchDate.split(' ')[0] }}</td>
                  <td class="size-16 center">{{ item2.style }}</td>
                  <td class="size-16 center">{{ item2.lotNo }}</td>
                  <td class="size-16 center">{{ item2.partName }}</td>
                  <td class="size-16 center">{{ item2.cutLayer }}</td>
                  <td class="size-16 center">{{ item2.pieceNum }}</td>
                  <td class="size-16 center">{{ item2.orderQty }}</td>
                  <td class="size-16 center">{{ item2.qty }}</td>
                  <td class="size-16 center">{{ item2.price }}</td>
                  <td class="size-16 center">{{ item2.amt }}</td>
                  <td class="size-16 center">{{ item2.financeYymm }}</td>
                  <td class="size-16 center">{{ item2.remark }}</td>
                </tr>
              </template>
            </tbody>
          </table>
        </div>
        <div class="mainTable">
          <span style="margin-left: 650px">{{ $t(`Print.TotalCutting`) }}:{{ item.total }}</span>
        </div>

        <div class="mainTable footer">
          <span style="margin-right: 100px">{{ $t(`Print.Leader`) }}:</span>
          <span>{{ $t(`Print.Operator`) }}:</span>
        </div>
      </div>
    </div>

    <Find
      @handleBlur="selectVal"
      :OriginalFilter="{ static: true }"
      @Launchform="Launchform3"
      :formList="formList"
      @findClicked="findData"
      @clickNumber="clickNumber"
      @clickNumber1="clickNumber1"
    />

    <el-card style="margin-top: 10px" shadow="always" :body-style="{ padding: '5px' }">
      <h1>{{ $t(`Print.SettleTheJob`) }}</h1>
      <Find
        @Launchform="Launchform"
        :OriginalFilter="{ static: true }"
        :searchImg="false"
        style="margin-bottom: 10px"
        :formList="formList1"
        @findClicked="findData1"
      />
      <div>
        <div style="width: 100%">
          <h1>{{ $t(`Print.InstructionProductionBreakdown`) }}</h1>
          <Table
            :summaryData="summaryData"
            summary
            @selectList="selection"
            :isLoading="isLoading"
            :selection="true"
            :tableHeader="tableHeader"
            :tableData="lotNoQueryTableDate"
            :TableHeight="95"
          />
        </div>
      </div>

      <PageModule :PageData="{ total, buttonS: true }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />

      <el-dialog width="20%" v-model="dialogVisible" :title="$t(`Print.CommandSelection`)">
        <qiTable
          @currentRow1="currentRowList2"
          :tableHeader="tableHeader7"
          :tableData="tableHeader7TableDate"
          :TableHeight="50"
          :outTableHeight="150"
        />
      </el-dialog>
    </el-card>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import fileRequest from '@/utils/fileRequest'
import { JudgmentInstruction } from '@/api/WarehouseDepartment/FactoryStorage/InputInsoleReceivingIssuingMaterials'
import JMessage from '@/utils/JMessage'
import { ElpoyleList } from '@/api/GeneralFinanceDepartment/GeneralFinanceDepartment/SubsidizeDeductionOperations'
export default defineComponent({
  name: 'CutTheJobOne'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import type { formListType } from '@/components/Find/index.vue'
import { ref, onMounted, computed } from 'vue'
import {
  lotNoQuery1,
  lotNoQuery,
  DropDownDataQuery,
  buttonBance,
  blanceQuery,
  sumEmpoilye
} from '@/api/GeneralFinanceDepartment/GeneralFinanceDepartment/CutTheJobOne'
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'

const dialogVisible = ref(false)

const currentRowList2 = (row: any) => {
  formList.value[2].inputValue = row.lotNo
  dialogVisible.value = false
}
const tableHeader7TableDate = ref([])

const lotNoList = ref('')

const lotNoQueryMethods1 = async () => {
  const result = await lotNoQuery1(lotNoList.value)
  tableHeader7TableDate.value = result.map((item: any) => {
    return { lotNo: item }
  })
}

// 判断指令是否存在
const selectVal = (row: any, inputList: any) => {
  if (inputList) {
    JudgmentInstructionMethods()
  }
}

const JudgmentInstructionMethods = async () => {
  if (lotNoList.value !== '') {
    const result = await JudgmentInstruction(lotNoList.value)
    if (result.code === 200) {
    } else {
      lotNoQueryMethods1()
      dialogVisible.value = true
    }
  }
}

const tableHeader7 = ref([
  {
    label: '指令',
    prop: 'lotNo',
    width: '160'
  }
])

// 每页显示的行数
const rowsPerPage = 23

const shouldShowHeader = (index1: any) => {
  return (index1 + 2) % rowsPerPage === 0
}

// 计算总页数
const totalPages = computed(() => Math.ceil(sumEmpoilyeTableDate.value.list.length / rowsPerPage))

const isLastPage = (pageIndex: number, totalPages: number) => {
  return pageIndex === totalPages - 1
}
// 分割数据为多页
const pages = computed(() => {
  const result = []
  for (let i = 0; i < sumEmpoilyeTableDate.value.list.length; i += rowsPerPage) {
    result.push(sumEmpoilyeTableDate.value.list.slice(i, i + rowsPerPage))
  }
  return result
})

// 日期
const formatCurrentDateTime = (date?: Date) => {
  const year = date!.getFullYear()
  const month = String(date!.getMonth() + 1).padStart(2, '0') // 使用padStart确保月份是两位数
  const day = String(date!.getDate()).padStart(2, '0') // 使用padStart确保日期是两位数

  // 返回格式化的日期时间字符串
  return `${year}-${month}-${day} `
}

const currentDate = ref(new Date())

const openFullScreen2 = () => {
  const loading = ElLoading.service({
    lock: true,
    text: '正在结算请稍后',
    background: 'rgba(0, 0, 0, 0.7)'
  })
  return loading
}

onMounted(() => {
  DropDownDataQueryMethods()
})

// 导出员工总表

const mainQuery1Methods = async () => {
  const qrCodeContainer = document.querySelector<any>('.printContent2')
  if (qrCodeContainer) {
    qrCodeContainer.style.display = 'block'

    const printWindow = window.open('', '导出员工汇总表')
    printWindow!.document.write(`
                  <!DOCTYPE html>
                  <html>
                      <head>
                      <title>打印指令领料作业</title>f
                      <link rel="stylesheet" type="text/css" href="print.css" media="print">
                      <style>
                          body, html {
                          margin: 0;
                          padding: 0;
                          }
                          @page {
                            }
                           @media print {  
                           .table123{
                           margin-top:40px
                           }
                       
                        .print-item {  
                          page-break-after: always; /* 每个二维码后分页 */  
                         
                        }  
                      } 
              .headerTable {
                  height: auto;
                  border: 0px solid #000;
                  text-align: center;
                  display: flex;
                  margin: 20px 20px 0px;
                  vertical-align: top;
                  width:50%
              }
              .title {
                  display: flex;
                  justify-content: center;
                  margin-bottom: 10px;
              }
  
              .center {
                  text-align: center;
              }
  
              .right {
                  text-align: right;
              }
  
              .left {
                  text-align: left;
              }
  
              .no-padding {
                  padding: 0;
              }
  
              .no-margin {
                  margin: 0;
              }
  
              .margin-5 {
                  margin: 5px;
              }
  
              .margin-top-5 {
                  margin-top: 5px;
              }
  
              .margin-top-15 {
                  margin-top: 15px;
              }
  
              .size-8 {
                  font-size: 8px !important;
              }
  
              .size-10 {
                  font-size: 10px;
              }
  
              .size-12 {
                  font-size: 12px;
              }
  
              .size-14 {
                  font-size: 14px;
              }
  
              .size-16 {
                  font-size: 17px;
              }
  
              .size-18 {
                  font-size: 18px;
              }
  
              .size-24 {
                  font-size: 24px;
              }
  
              #date-tip {
                  position: relative;
              }
  
              span.tip {
                  display: inline-block;
                  height: 14px;
                  line-height: 14px;
                  margin-right: 30px;
              }
  
              table {
                  font-size: 10px;
                  border-collapse: collapse;
                  border-spacing: 0;
                  border-collapse: collapse;
                  border-spacing: 0;
                  empty-cells: show;
                  width: 100%;
              }
  
              table th,
              table td {
                  border: 1px solid #000;
                  font-size: 12px;
              }
  
              table.no-border,
              table.no-border th,
              table.no-border td {
                  border: 0px;
              }
  
              table td.no-left-border {
                  border-left: 0px;
              }
  
              table td.no-right-border {
                  border-right: 0px;
              }
  
              .mainTable {
                  margin: 0 10px;
              }
  
              /* 备料派工单汇总表 */
              .header {
                  display: flex;
                  justify-content: space-evenly;
              }
  
              .footer {
                  margin-top: 20px;
                  margin-right: 100px;
                  display: flex;
                  justify-content: right;
              }
                      
                          /* 可以在这里添加更多自定义的打印样式 */
                      </style>
                      </head>
                      <body>
                  `)

    // 将 .qrCodeContainer 的内容复制到打印窗口的 body 中
    const cloneContainer = qrCodeContainer.cloneNode(true)
    printWindow!.document.body.appendChild(cloneContainer)

    printWindow!.document.write(`
                      </body>
                  </html>
                  `)
    printWindow!.document.close()

    // 开始打印
    printWindow!.print()

    // 打印完成后，可以恢复 .qrCodeContainer 的原始显示状态
    qrCodeContainer.style.display = 'none'
  }
}

const sumEmpoilyeTableDate = ref<any>([])

const sumEmpoilyeMethods = async () => {
  try {
    const result = await sumEmpoilye()
    sumEmpoilyeTableDate.value = result.data
    if (result.code === 200) {
      setTimeout(() => {
        mainQuery1Methods()
      }, 500)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.warning('导出失败')
  }
}

const blanceQueryMethods = async () => {
  try {
    const result = await blanceQuery(lotNoQueryParms.value)
    total.value = result.total
    summaryData.value[0].num = result.qtyTotal
    summaryData.value[1].num = result.amtTotal
  } catch (error) {
    JMessage.error('指令产量明细查询出错')
  }
}

const summaryData = ref<any>([
  {
    index: 13,
    num: 0
  },
  {
    index: 15,
    num: 0
  }
])

// 按钮功能
const buttonBanceParms = ref<any>({
  accountName: '',
  choose: '',
  financeYymm: '',
  list: [],
  remark: '',
  dispatchStartDate: '',
  dispatchEndDate: ''
})

const selection = (row: any) => {
  buttonBanceParms.value.list = row.map((item: any) => {
    return item
  })
}

const findData1 = async (row: string) => {
  if (row === '结算确认') {
    let list = true
    buttonBanceParms.value.list.map((item: any) => {
      if (item.price !== null && item.printFlag !== 'Y') {
        list = false
      }

      return item
    })
    buttonBanceParms.value.choose = 1
    if (buttonBanceParms.value.accountName === '' || buttonBanceParms.value.financeYymm === '' || buttonBanceParms.value.dispatchStartDate === '') {
      JMessage.warning('结算方式和结算月份还有需要结算的数据不可为空')
    } else {
      buttonBanceMethods()
    }
  }
  if (row === '取消结算') {
    buttonBanceParms.value.choose = 2
    if (buttonBanceParms.value.dispatchStartDate === '') {
      JMessage.warning('请选择正确的日期进行取消结算')
    } else {
      buttonBanceMethods()
    }
  }

  if (row === '财务备注') {
    buttonBanceParms.value.choose = 3
    if (buttonBanceParms.value.remark === '' || buttonBanceParms.value.list.length === 0) {
      JMessage.warning('请勾选需要进行备注的数据并且备注不可为空')
    } else {
      buttonBanceMethods()
    }
  }

  if (row === '导出月份汇总表') {
    if (lotNoQueryParms.value.financeYymm === '') {
      JMessage.warning('请先输入月份后进行导出')
    } else {
      const res = (await fileRequest.post(`/salaryFile/downloadCuttingCollect?financeYymm=${lotNoQueryParms.value.financeYymm}`)) as any
      const link = document.createElement('a') // 利用a标签自定义下载文件名
      let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
      link.style.display = 'none'
      //设置连接
      link.href = window.URL.createObjectURL(blob)
      link.download = decodeURI(`${res.headers['content-disposition'].split(`utf-8''`)[1]}`) //自定义文件名字
      document.body.appendChild(link)
      //模拟点击事件
      link.click()
      document.body.removeChild(link)
    }
  }

  if (row === '导出员工汇总表') {
    const res = (await fileRequest.post(`/salaryFile/export/pdf`, lotNoQueryParms.value)) as any
    const link = document.createElement('a') // 利用a标签自定义下载文件名
    let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
    link.style.display = 'none'
    //设置连接
    link.href = window.URL.createObjectURL(blob)
    link.download = `员工汇总表${Date.now()}.pdf` //自定义文件名字
    document.body.appendChild(link)
    //模拟点击事件
    link.click()
    document.body.removeChild(link)
    // sumEmpoilyeMethods()23
  }
}

const Launchform = (row: any) => {
  buttonBanceParms.value.accountName = row[1].selectValue
  buttonBanceParms.value.financeYymm = row[0].inputValue
  buttonBanceParms.value.remark = row[2].inputValue
}

const buttonBanceMethods = async () => {
  let active = openFullScreen2()
  const mergedParms = {
    ...buttonBanceParms.value,
    financeYymms: lotNoQueryParms.value.financeYymm,
    ...Object.fromEntries(Object.entries(lotNoQueryParms.value).filter(([key]) => key !== 'financeYymm'))
  }

  try {
    const result = await buttonBance(mergedParms)
    if (result.code === 200) {
      lotNoQueryMethods()
      active.close()
      JMessage.success(result.message)
    } else {
      active.close()
      handleCloseMateriaLKlc(result.message)
    }
  } catch (error) {
    JMessage.error('功能异常请重试')
  }
}

const handleCloseMateriaLKlc = (lotNo: string, _done?: () => void) => {
  ElMessageBox.confirm(lotNo)
    .then(async () => {})
    .catch(() => {})
}

// 下拉框数据查询

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

const DropDownDataQueryMethods = async () => {
  try {
    let NewArray = []
    const result = await DropDownDataQuery()

    formList.value[0].selectOptions = EvaluatesTheArrayReturnValue(result.types)
    formList.value[1].selectOptions = EvaluatesTheArrayReturnValue1(result.partNames)
    formList.value[7].selectOptions = EvaluatesTheArrayReturnValue1(result.deptNames)

    NewArray = result.workerNames.reduce((arr: any, item: any) => {
      if (item !== null) {
        // 只添加非空的 typeName 和 typeNo
        arr.push(item.name + ' ' + item.idNo)
      }
      return arr
    }, [])

    // formList.value[8].selectOptions = EvaluatesTheArrayReturnValue1(NewArray)
  } catch (error) {
    JMessage.error('下拉框数据查询出错')
  }
}

// 员工查询
const ElpoyleListMethods = async () => {
  try {
    let NewArray = []

    const result = await ElpoyleList()

    NewArray = result.reduce((arr: any, item: any) => {
      if (item.deptNo && item.deptName) {
        // 只添加非空的 typeName 和 typeNo
        arr.push(item.workerId + ' ' + item.deptName + ' ' + item.name)
      }
      return arr
    }, [])

    formList.value[8].selectOptions = EvaluatesTheArrayReturnValue1(NewArray)
  } catch (error) {
    JMessage.error('扣款查询出错')
  }
}

// 指令产量明细查询
const isLoading = ref(false)

const lotNoQueryParms = ref<any>({
  balanceNo: '',
  deptName: '',
  dispatchEndDate: '',
  dispatchStartDate: '',
  financeYymm: '',
  flag: '',
  lotNo: '',
  pageNum: 1,
  pageSize: 40,
  partName: '',
  pflag: '',
  style: '',
  type: '',
  workerName: '',
  seqNo: ''
})

const EvaluatesTheArrayReturnValue1 = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      value: item,
      label: item
    }
  })
}

const Launchform3 = (row: any) => {
  lotNoQueryParms.value.type = row[0].selectValue
  lotNoQueryParms.value.partName = row[1].selectValue
  lotNoQueryParms.value.lotNo = row[2].inputValue
  lotNoList.value = row[2].inputValue
  lotNoQueryParms.value.style = row[3].inputValue
  lotNoQueryParms.value.balanceNo = row[4].inputValue
  lotNoQueryParms.value.financeYymm = row[5].inputValue

  lotNoQueryParms.value.dispatchStartDate = row[6].dateValue[0]
  lotNoQueryParms.value.dispatchEndDate = row[6].dateValue[1]
  lotNoQueryParms.value.seqNo = row[19].inputValue

  buttonBanceParms.value.dispatchStartDate = row[6].dateValue[0]
  buttonBanceParms.value.dispatchEndDate = row[6].dateValue[1]

  lotNoQueryParms.value.deptName = row[7].selectValue
  lotNoQueryParms.value.workerName = row[8].selectValue.split(' ')[2]
}

const clickNumber = (row: string) => {
  switch (row) {
    case '1': {
      lotNoQueryParms.value.flag = null
      break
    }
    case '2': {
      lotNoQueryParms.value.flag = 2
      break
    }
    case '3': {
      lotNoQueryParms.value.flag = 1
      break
    }
  }
  blanceQueryMethods()

  lotNoQueryMethods()
}

const clickNumber1 = (row: string) => {
  switch (row) {
    case '0': {
      lotNoQueryParms.value.pflag = null
      break
    }
    case '1': {
      lotNoQueryParms.value.pflag = 2
      break
    }
    case '2': {
      lotNoQueryParms.value.pflag = 1
      break
    }
  }
  blanceQueryMethods()

  lotNoQueryMethods()
}

const lotNoQueryTableDate = ref([])

const lotNoQueryMethods = async () => {
  isLoading.value = true
  const result = await lotNoQuery(lotNoQueryParms.value)
  if (result.code === 200 && Array.isArray(result.data.list)) {
    lotNoQueryTableDate.value = result.data.list.map((item: any) => {
      if (item.priceFlag !== 'Y') {
        item.backgroundColor = '#FFE0E0'
      }
      return item
    })
  } else {
    JMessage.error(result.message)
  }

  if (Array.isArray(result.data) && lotNoQueryParms.value.lotNo !== '') {
    if (result.code === 200) {
      formList.value[2].selectOptions = EvaluatesTheArrayReturnValue(result.data)
      formList.value[2].selectValue = ''
      JMessage.success(`指令获取成功`)
    } else {
      JMessage.error(result.message)
    }
  }
  isLoading.value = false
}

const total = ref(0)

const handleSizeChange = (val: number) => {
  lotNoQueryParms.value.pageSize = val
  lotNoQueryMethods()
}

const handleCurrentChange = (val: number) => {
  lotNoQueryParms.value.pageNum = val
  lotNoQueryMethods()
}

onMounted(() => {
  blanceQueryMethods()

  lotNoQueryMethods()

  ElpoyleListMethods()
})

const formList = ref<any[]>([
  {
    type: 'select',
    selectValue: '',
    selectP: '类型',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'selectJ',
    selectValue: '',
    selectP: '部位',
    selectLabel: '',
    selectOptions: []
  },
  // {
  //   type: 'select111',
  //   selectValue: '',
  //   selectP: '指令',
  //   selectLabel: '',
  //   selectOptions: []
  // },
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: '',
    inputList: true
  },
  {
    type: 'input',
    inputPlaceholder: '型体',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '结算单号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '结算月份',
    inputValue: ''
  },
  {
    type: 'date',
    dateLabel: '派工日期',
    dateValue: ''
  },
  {
    type: 'selectJ',
    selectValue: '',
    selectP: '部门',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'selectJ',
    selectValue: '',
    selectP: '员工',
    selectLabel: '',
    selectOptions: [],
    selectV2Width: '300px'
  },
  {
    type: 'radio',
    checkboxLabel: '未结算',
    label: '3'
  },
  {
    type: 'radio',
    checkboxLabel: '已结算',
    label: '2'
  },
  {
    type: 'radio',
    checkboxLabel: '全部',
    label: '1'
  },
  {
    type: 'radio1',
    checkboxLabel: '没单价',
    label: '2'
  },
  {
    type: 'radio1',
    checkboxLabel: '有单价',
    label: '1'
  },
  {
    type: 'radio1',
    checkboxLabel: '全部',
    label: '0'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '退出'
  },
  {
    type: 'button',
    checkboxLabel: '导出'
  },
  {
    type: 'button',
    checkboxLabel: '搜索'
  },
  {
    type: 'input',
    inputPlaceholder: '请输入序号',
    inputValue: ''
  }
])

const formList1 = ref<any[]>([
  {
    type: 'input',
    inputPlaceholder: '结算月份',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '结算方式',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: `荣阳大货`,
        optionLabel: `荣阳大货`,
        optionValue: `荣阳大货`
      },
      {
        optionKey: `荣信`,
        optionLabel: `荣信`,
        optionValue: `荣信`
      }
    ]
  },
  {
    type: 'input',
    inputPlaceholder: '备注',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '财务备注'
  },
  {
    type: 'button',
    checkboxLabel: '结算确认'
  },
  {
    type: 'button',
    checkboxLabel: '取消结算'
  },
  {
    type: 'button',
    checkboxLabel: '导出员工汇总表'
  },
  {
    type: 'button',
    checkboxLabel: '导出月份汇总表'
  }
])

const findData = async (count: string) => {
  if (count === '置空') {
    clearFormList5()
  }

  if (count === '导出') {
    const res = (await fileRequest.post(`/salaryFile/downPcCuttingSalaryDetail`)) as any
    const link = document.createElement('a') // 利用a标签自定义下载文件名
    let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
    link.style.display = 'none'
    //设置连接
    link.href = window.URL.createObjectURL(blob)
    link.download = decodeURI(`${res.headers['content-disposition'].split(`utf-8''`)[1]}`) //自定义文件名字
    document.body.appendChild(link)
    //模拟点击事件
    link.click()
    document.body.removeChild(link)

    // if (res.code === 200) {
    //   JMessage.success('导出成功')
    //   getTable15List()
    // } else {
    //   JMessage.error(res.message)
    // }
  }
  if (count === '搜索') {
    blanceQueryMethods()

    lotNoQueryMethods()
  }
}

const clearFormList5 = () => {
  formList.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    if (item.type === 'selectJ') {
      item.selectValue = ''
    }
    if (item.type === 'select111') {
      item.selectValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
  })

  //   lotNoQueryMethods()

  // blanceQueryMethods()
}

// 表格数据

const tableHeader = ref([
  {
    label: '类型',
    prop: 'type'
  },
  {
    label: '指令号',
    prop: 'lotNo'
  },
  {
    label: '型体',
    prop: 'style'
  },
  {
    label: '生产日期',
    prop: 'dispatchDate'
  },
  {
    label: '部门',
    prop: 'deptName'
  },
  {
    label: '工号',
    prop: 'workerId'
  },
  {
    label: '姓名',
    prop: 'name'
  },
  {
    label: '序号',
    prop: 'seqNo'
  },
  {
    label: '部位',
    prop: 'partName'
  },
  {
    label: '裁层',
    prop: 'cutLayer'
  },
  {
    label: '每双片数',
    prop: 'pieceNum'
  },
  {
    label: '订单数量',
    prop: 'orderQty'
  },
  {
    label: '派工数量',
    prop: 'qty'
  },
  {
    label: '单价',
    prop: 'price',
    backgroundColor: true
  },
  {
    label: '金额',
    prop: 'amt'
  },
  {
    label: '结算确认',
    prop: 'accountName'
  },
  {
    label: '结算月份',
    prop: 'financeYymm'
  },
  {
    label: '结算单号',
    prop: 'balanceNo'
  },
  {
    label: '财务备注',
    prop: 'remark'
  },
  {
    label: '封账标识',
    prop: 'priceCfmFlag'
  }
])
</script>

<style lang="less" scoped>
:deep(.el-table__cell) {
  color: black !important;
}

:deep(.A.el-table th.el-table__cell:nth-child(1) .cell) {
  visibility: hidden;
}

.qrCodeContainer {
  display: none;
}

.headerTable {
  height: auto;
  border: 0px solid #000;
  text-align: center;
  display: flex;
  margin: 20px 20px 0px;
  vertical-align: top;
}

.title {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.left {
  text-align: left;
}

.no-padding {
  padding: 0;
}

.no-margin {
  margin: 0;
}

.margin-5 {
  margin: 5px;
}

.margin-top-5 {
  margin-top: 5px;
}

.margin-top-15 {
  margin-top: 15px;
}

.size-8 {
  font-size: 8px !important;
}

.size-10 {
  font-size: 10px;
}

.size-12 {
  font-size: 12px;
}

.size-14 {
  font-size: 14px;
}

.size-16 {
  font-size: 17px;
}

.size-18 {
  font-size: 18px;
}

.size-24 {
  font-size: 24px;
}

#date-tip {
  position: relative;
}

span.tip {
  display: inline-block;
  height: 14px;
  line-height: 14px;
  margin-right: 30px;
}

table {
  font-size: 10px;
  border-collapse: collapse;
  border-spacing: 0;
  border-collapse: collapse;
  border-spacing: 0;
  empty-cells: show;
  width: 100%;
}

table th,
table td {
  border: 1px solid #000;
  font-size: 12px;
}

table.no-border,
table.no-border th,
table.no-border td {
  border: 0px;
}

table td.no-left-border {
  border-left: 0px;
}

table td.no-right-border {
  border-right: 0px;
}

.mainTable {
  margin: 0 20px;
}

/* 备料派工单汇总表 */
.header {
  display: flex;
  justify-content: space-evenly;
}

.footer {
  margin-top: 20px;
  margin-right: 100px;
  display: flex;
  justify-content: right;
}
h1 {
  font-size: 14px;
  margin-bottom: 5px;
}

.printContent2 {
  display: none;
}
</style>
